package com.shuogesha.platform.feign;

import static com.shuogesha.common.web.mongo.SimplePage.cpn;

import java.io.UnsupportedEncodingException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.shuogesha.common.util.JsonResult;
import com.shuogesha.platform.client.MenuFeignClient;
import com.shuogesha.platform.entity.Menu;

@RestController
@RequestMapping("/api/menu/")
public class MenuFeignAct {
	@RequestMapping(value = "/list")
	public Object v_list(String name, Integer pageNo, Integer pageSize) throws UnsupportedEncodingException {
		return menuFeignClient.list(name, cpn(pageNo), pageSize);
	}

	@RequestMapping(value = "/get")
	public Object v_get(Long id) {
		return menuFeignClient.get(id);
	}

	@RequestMapping(value = "/save", method = RequestMethod.POST)
	public Object o_save(@RequestBody Menu bean) {

		return menuFeignClient.save(bean);
	}

	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public Object o_update(@RequestBody Menu bean) {
		return menuFeignClient.update(bean);
	}

	@RequestMapping(value = "/delete")
	public Object o_delete(Long[] ids) {
		return menuFeignClient.delete(ids);
	}

	@Autowired
	public MenuFeignClient menuFeignClient;
	
	@RequestMapping(value = "/getAllNodes")
	public JsonResult<List<Menu>> getAllNodes(@RequestParam("id") Long id){
		return menuFeignClient.getAllNodes(id);
	}
	
	@RequestMapping(value = "/getMenus")
	public List<Menu> getMenus(@RequestParam("pid") Long pid,@RequestParam("type") String type){
		return menuFeignClient.getMenus(pid, type);
	}
}
